     //引入的是一级路由
import Home from '@/pages/Home';
import Search from '@/pages/Search';
import Login from '@/pages/Login';
import Register from '@/pages/Register';
import Detail from '@/pages/Detail';
import AddCartSuccess from '@/pages/AddCartSuccess'
import ShopCart from '@/pages/ShopCart'
export default [
        {
            name:'home',
            path:'/home',
            component:Home,
            //路由元信息===控制footer的显示与隐藏
            meta:{show:true},
        },
        {  //代表params参数可有可无，务必要加上问号 ?
            path:'/search/:keyWord?',
            component:Search,
            meta:{show:true},
            //命名路由
            name:'search',
            //路由也可以传递props数据，拥有三种写法
            //如果props被设置为true ,param参数将会被设置为组件属性
            //  props:true
            props:(route)=>({keyWord:route.params.keyWord,k:route.query.k})
        },
        {   
            name:'login',
            path:'/login',
            component:Login,
            meta:{show:false},
        },
        {   
            name:'register',
            path:'/register',
            component:Register,
            meta:{show:false},
        },
        {  //页面重定向
            path:'/', 
            redirect:'/home'
        },
        {
            path:'/detail/:skuId',
            component:Detail,
            meta:{show:true},
        },
        //加入购物车路由
        {
            name:"addcartsuccess",
            path:'/addcartsuccess',
            component:AddCartSuccess,
            meta:{show:true},
        },
        {
            name:"shopcart",
            path:'/shopcart',
            component:ShopCart,
            meta:{show:true},
        }
    ]

 